home *** CD-ROM | disk | FTP | other *** search
/ Sports Illustrated for Kids - Awesome Athletes! / Sports Illustrated for Kids - Awesome Athletes!.iso / ma.dir / 00001_movie script01.ls next >
Encoding:
Text File  |  1996-04-18  |  23.8 KB  |  766 lines

  1. global gMANumMatches, gMAsound, gMALev, gMADebug
  2.  
  3. on MAmovie
  4.   global MAmenuList, MAnewGame, MASavedList, gHSState, gMAnextLev, gMAmenu, gMAgameMarker, gMALev, gMAsound, gMAflip, MAflavor
  5.   set the exitLock to 1
  6.   set gMADebug to 1
  7.   EnableIdleAnim(47, 48)
  8.   set gMANumMatches to -1
  9.   puppetSprite(44, 1)
  10.   set the visible of sprite 44 to 0
  11.   set MAmenuList to [[#menu1a, #menu2a, #menu3a], [#menu1b, #menu2b, #menu3b], [#menu1c, #menu2c, #menu3c], [#menu1d, #menu2d, #menu3d]]
  12.   set the keyDownScript to "MAcheckKey"
  13.   set the text of cast "guessField" to " "
  14.   set the textSize of field "guessField" to 12
  15.   set the text of cast "guessField" to EMPTY
  16.   set MASavedList to []
  17.   set temp to HSStateGet("MA", "savedList")
  18.   set MASavedList to value(temp)
  19.   set temp to HSStateGet("MA", "NumMatches")
  20.   set gMANumMatches to value(temp)
  21.   if listp(MASavedList) = 0 then
  22.     set MAnewGame to 1
  23.     set gMAgameMarker to 0
  24.     set gMALev to 1
  25.     set gMAnextLev to 1
  26.     set gMAsound to 1
  27.     set gMAflip to 1
  28.     set MAflavor to getAt(MAmenuList, 1)
  29.     set gMAmenu to GetCurrMenu()
  30.     MAinitGame()
  31.   end if
  32.   if listp(MASavedList) = 1 then
  33.     MAgetStates()
  34.     MAinitGame()
  35.   end if
  36.   set gMAflip to value(HSStateGet("opt", "MAFlip"))
  37.   if gMAflip = 1 then
  38.     set MAflavor to getAt(MAmenuList, 2)
  39.     set gMAmenu to GetCurrMenu()
  40.   end if
  41.   if gMAflip = 0 then
  42.     set MAflavor to getAt(MAmenuList, 4)
  43.     set gMAmenu to GetCurrMenu()
  44.   end if
  45. end
  46.  
  47. on MAdoConButtons aForceMenu
  48.   global gMAmenu, gMAcurrAth, gMAsound, gMAflip, gMALev, MAflavor, gMAnextLev, gSISystem, MAclearedGrid
  49.   if voidp(aForceMenu) then
  50.     set aForceMenu to 0
  51.   end if
  52.   StartBufferingEvents()
  53.   repeat while aForceMenu or ((the mouseH > 0) and (the mouseH < 640) and (the mouseV < 16))
  54.     if the mouseV < 0 then
  55.       exit repeat
  56.     end if
  57.     if aForceMenu or ((the mouseH > 0) and (the mouseH < 640) and (the mouseV < 16)) then
  58.       puppetSprite(44, 1)
  59.       set the castNum of sprite 44 to gMAmenu
  60.       updateStage()
  61.     end if
  62.     set the visible of sprite 44 to 1
  63.     repeat while (the mouseH > 115) and (the mouseH < 205) and (the mouseV < 16)
  64.       if (the mouseH > 115) and (the mouseH < 205) and (the mouseV < 16) then
  65.         set the castNum of sprite 45 to the number of cast "how-hi.btn"
  66.       end if
  67.       updateStage()
  68.       if the mouseDown then
  69.         LaunchHelp()
  70.         exit repeat
  71.       end if
  72.     end repeat
  73.     repeat while (the mouseH > 0) and (the mouseH < 102) and (the mouseV < 16)
  74.       if (the mouseH > 0) and (the mouseH < 102) and (the mouseV < 16) then
  75.         set the castNum of sprite 45 to the number of cast "new puz-hi.btn"
  76.       end if
  77.       updateStage()
  78.       if the mouseDown then
  79.         puppetSprite(42, 0)
  80.         puppetSprite(43, 0)
  81.         puppetSprite(46, 0)
  82.         updateStage()
  83.         go("gameFrame")
  84.         set the locH of sprite 1 to the locH of sprite 1
  85.         updateStage()
  86.         HSStatePut("ma", "not1stTime", "1")
  87.         set the text of cast "guessField" to EMPTY
  88.         MAinitGame()
  89.         goSetUp(1)
  90.         set the visible of sprite 44 to 1
  91.         exit repeat
  92.       end if
  93.     end repeat
  94.     repeat while (the mouseH > 225) and (the mouseH < 315) and (the mouseV < 16)
  95.       if the frameLabel <> "gameFrame" then
  96.         exit repeat
  97.       end if
  98.       if (the mouseH > 225) and (the mouseH < 315) and (the mouseV < 16) then
  99.         set the castNum of sprite 45 to the number of cast "solve-hi.btn"
  100.       end if
  101.       updateStage()
  102.       if the mouseDown then
  103.         if not voidp(gMAcurrAth) then
  104.           if gMANumMatches <> -1 then
  105.             puppetSprite(40, 1)
  106.             set the text of cast "guessField" to gMAcurrAth
  107.             repeat with I = 16 to 39
  108.               puppetSprite(I, 0)
  109.             end repeat
  110.             set MAclearedGrid to list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
  111.             if gMALev = 1 then
  112.               MAshowLetters()
  113.             end if
  114.             MAdoHistory()
  115.           end if
  116.         end if
  117.         exit repeat
  118.       end if
  119.     end repeat
  120.     repeat while (the mouseH > 330) and (the mouseH < 420) and (the mouseV < 16) and (the mouseDown = 0)
  121.       if gMAnextLev = 1 then
  122.         if (the mouseH > 330) and (the mouseH < 420) and (the mouseV < 16) then
  123.           set the castNum of sprite 45 to the number of cast "lev01-hi.btn"
  124.         end if
  125.         updateStage()
  126.       end if
  127.       if gMAnextLev = 2 then
  128.         if (the mouseH > 330) and (the mouseH < 420) and (the mouseV < 16) then
  129.           set the castNum of sprite 45 to the number of cast "lev02-hi.btn"
  130.         end if
  131.         updateStage()
  132.       end if
  133.       if gMAnextLev = 3 then
  134.         if (the mouseH > 330) and (the mouseH < 420) and (the mouseV < 16) then
  135.           set the castNum of sprite 45 to the number of cast "lev03-hi.btn"
  136.         end if
  137.         updateStage()
  138.       end if
  139.       if the mouseDown then
  140.         set gMAnextLev to gMAnextLev + 1
  141.         if gMAnextLev > 3 then
  142.           set gMAnextLev to 1
  143.         end if
  144.         set gMAmenu to GetCurrMenu()
  145.         if gMALev = 10 then
  146.           set gMALev to 2
  147.           set gMAmenu to GetCurrMenu()
  148.           exit repeat
  149.         end if
  150.         if gMALev = 20 then
  151.           set gMALev to 3
  152.           set gMAmenu to GetCurrMenu()
  153.           exit repeat
  154.         end if
  155.         if gMALev = 30 then
  156.           set gMALev to 1
  157.           set gMAmenu to GetCurrMenu()
  158.           exit repeat
  159.         end if
  160.         updateStage()
  161.       end if
  162.     end repeat
  163.     repeat while (the mouseH > 435) and (the mouseH < 530) and (the mouseV < 16) and (the mouseDown = 0)
  164.       if gMAsound = 1 then
  165.         if (the mouseH > 435) and (the mouseH < 530) and (the mouseV < 16) then
  166.           set the castNum of sprite 45 to the number of cast "sound on-hi.btn"
  167.         end if
  168.       end if
  169.       if gMAsound = 0 then
  170.         if (the mouseH > 435) and (the mouseH < 530) and (the mouseV < 16) then
  171.           set the castNum of sprite 45 to the number of cast "sound off-hi.btn"
  172.         end if
  173.       end if
  174.       updateStage()
  175.       if the mouseDown then
  176.         if gMAsound = 1 then
  177.           set gMAsound to 0
  178.           set the soundEnabled to 0
  179.           if gMAflip = 1 then
  180.             set MAflavor to getAt(MAmenuList, 2)
  181.             set gMAmenu to GetCurrMenu()
  182.             exit repeat
  183.           end if
  184.           if gMAflip = 0 then
  185.             set MAflavor to getAt(MAmenuList, 4)
  186.             set gMAmenu to GetCurrMenu()
  187.             exit repeat
  188.           end if
  189.         end if
  190.         if gMAsound = 0 then
  191.           set gMAsound to 1
  192.           set the soundEnabled to 1
  193.           if gMAflip = 1 then
  194.             set MAflavor to getAt(MAmenuList, 1)
  195.             set gMAmenu to GetCurrMenu()
  196.             exit repeat
  197.           end if
  198.           if gMAflip = 0 then
  199.             set MAflavor to getAt(MAmenuList, 3)
  200.             set gMAmenu to GetCurrMenu()
  201.             exit repeat
  202.           end if
  203.         end if
  204.         updateStage()
  205.       end if
  206.     end repeat
  207.     repeat while (the mouseH > 540) and (the mouseH < 640) and (the mouseV < 16) and (the mouseDown = 0)
  208.       if gMAflip = 1 then
  209.         if (the mouseH > 540) and (the mouseH < 640) and (the mouseV < 16) then
  210.           set the castNum of sprite 45 to the number of cast "flip on-hi.btn"
  211.         end if
  212.       end if
  213.       if gMAflip = 0 then
  214.         if (the mouseH > 540) and (the mouseH < 640) and (the mouseV < 16) then
  215.           set the castNum of sprite 45 to the number of cast "flip off-hi.btn"
  216.         end if
  217.       end if
  218.       updateStage()
  219.       if the mouseDown then
  220.         if gMAflip = 1 then
  221.           HSStatePut("opt", "MAFlip", "0")
  222.           set gMAflip to 0
  223.           if gMAsound = 1 then
  224.             set MAflavor to getAt(MAmenuList, 3)
  225.             set gMAmenu to GetCurrMenu()
  226.             exit repeat
  227.           end if
  228.           if gMAsound = 0 then
  229.             set MAflavor to getAt(MAmenuList, 4)
  230.             set gMAmenu to GetCurrMenu()
  231.             exit repeat
  232.           end if
  233.         end if
  234.         if gMAflip = 0 then
  235.           HSStatePut("opt", "MAFlip", "1")
  236.           set gMAflip to 1
  237.           if gMAsound = 1 then
  238.             set MAflavor to getAt(MAmenuList, 1)
  239.             set gMAmenu to GetCurrMenu()
  240.             exit repeat
  241.           end if
  242.           if gMAsound = 0 then
  243.             set MAflavor to getAt(MAmenuList, 2)
  244.             set gMAmenu to GetCurrMenu()
  245.             exit repeat
  246.           end if
  247.         end if
  248.         updateStage()
  249.       end if
  250.     end repeat
  251.     if aForceMenu then
  252.       exit repeat
  253.     end if
  254.   end repeat
  255.   repeat while (the mouseH > 361) and (the mouseH < 455) and (the mouseV > 455)
  256.     if (the mouseH > 361) and (the mouseH < 455) and (the mouseV > 455) then
  257.       set the castNum of sprite 46 to the number of cast "guess-hi.btn"
  258.     end if
  259.     updateStage()
  260.     if the mouseDown then
  261.       MAdoGuess()
  262.       updateStage()
  263.     end if
  264.   end repeat
  265.   EndBufferingEvents()
  266.   if not aForceMenu then
  267.     set the visible of sprite 44 to 0
  268.   end if
  269. end
  270.  
  271. on MAcheckKey
  272.   if (the key = RETURN) or (the key = ENTER) then
  273.     MAdoGuess()
  274.   else
  275.     if gMAsound then
  276.       puppetSound("type.aif")
  277.       updateStage()
  278.     end if
  279.   end if
  280.   if (the text of cast "guessField" = RETURN) or (the text of cast "guessField" = ENTER) then
  281.     set the text of cast "guessField" to EMPTY
  282.   end if
  283. end
  284.  
  285. on MAdoGuess
  286.   global gMAcurrAth, gMAgameMarker, MAclearedGrid
  287.   if gMAsound then
  288.     puppetSound("return.aif")
  289.     updateStage()
  290.   end if
  291.   set vTmp to the text of cast "guessField"
  292.   if the text of cast "guessField" = gMAcurrAth then
  293.     set gMAgameMarker to gMAgameMarker + 1
  294.     repeat with vMAi = 16 to 39
  295.       set the loc of sprite vMAi to point(-500, -500)
  296.       puppetSprite(vMAi, 0)
  297.     end repeat
  298.     set MAclearedGrid to list(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
  299.     if gMAsound then
  300.       puppetSound("Ding.aif")
  301.       updateStage()
  302.     end if
  303.     set the visible of sprite 43 to 0
  304.     set the visible of sprite 42 to 0
  305.     MAshowLetters()
  306.     MAdoHistory()
  307.   else
  308.     beep()
  309.     set the selStart to 0
  310.     set the text of cast "guessField" to EMPTY
  311.     put EMPTY before char 1 of field "guessField"
  312.   end if
  313. end
  314.  
  315. on MAdoHistory
  316.   global gMAathStr
  317.   puppetSprite(41, 0)
  318.   set the visible of sprite 41 to 1
  319.   set the visible of sprite 43 to 0
  320.   set the visible of sprite 42 to 0
  321.   set gMANumMatches to -1
  322.   puppetSprite(42, 1)
  323.   puppetSprite(43, 1)
  324.   set the stretch of sprite 43 to 0
  325.   put gMAathStr && the number of cast string("HS" & gMAathStr & ".pct")
  326.   set the castNum of sprite 43 to the number of cast string("HS" & gMAathStr & ".pct")
  327.   set the locH of sprite 43 to 209
  328.   set the locV of sprite 43 to 201
  329.   set the castNum of sprite 42 to the number of cast string("MA" & gMAathStr)
  330.   set the locH of sprite 42 to 293
  331.   set the locV of sprite 42 to 125
  332.   go("Solved")
  333. end
  334.  
  335. on MAtimer ticks
  336.   startTimer()
  337.   repeat while the timer < ticks
  338.     nothing()
  339.   end repeat
  340. end
  341.  
  342. on MAturnPuppets aMAlow, aMAhigh, aMAway
  343.   repeat with N = aMAlow to aMAhigh
  344.     puppetSprite(N, aMAway)
  345.   end repeat
  346. end
  347.  
  348. on MAturnVisible aMAlow, aMAhigh, aMAway
  349.   repeat with N = aMAlow to aMAhigh
  350.     MAturnPuppets(N, N, aMAway)
  351.     set the visible of sprite N to aMAway
  352.   end repeat
  353. end
  354.  
  355. on MAinitGame
  356.   global gMAnextLev, gMALev, MAgridList, gMAlowSprite, gMAhighSprite, gMAlowLetterSprite, gMAmatch, MAclearedGrid
  357.   if gMAnextLev > 0 then
  358.     set gMALev to gMAnextLev
  359.   else
  360.     set gMALev to 1
  361.   end if
  362.   MAallOFF()
  363.   doMAathList()
  364.   set MAgridList to [point(77, 55), point(174, 55), point(271, 55), point(368, 55), point(465, 55), point(562, 55), point(77, 156), point(174, 156), point(271, 156), point(368, 156), point(465, 156), point(562, 156), point(77, 257), point(174, 257), point(271, 257), point(368, 257), point(465, 257), point(562, 257), point(77, 358), point(174, 358), point(271, 358), point(368, 358), point(465, 358), point(562, 358)]
  365.   set gMAlowSprite to 16
  366.   set gMAhighSprite to 39
  367.   set gMAlowLetterSprite to 2
  368.   set gMAmatch to EMPTY
  369.   set MAclearedGrid to list()
  370.   repeat with N = 1 to 24
  371.     append(MAclearedGrid, 1)
  372.   end repeat
  373.   MAdoAnimList()
  374. end
  375.  
  376. on MAsetTile aMAwhichTile, aMAwhatNum, aAltSprite
  377.   global gMAlowSprite, MAgridList
  378.   if voidp(aAltSprite) then
  379.     puppetSprite(aMAwhichTile + gMAlowSprite - 1, 1)
  380.     set the castNum of sprite (aMAwhichTile + gMAlowSprite - 1) to cast aMAwhatNum
  381.     set the loc of sprite (aMAwhichTile + gMAlowSprite - 1) to getAt(MAgridList, aMAwhichTile)
  382.   else
  383.     puppetSprite(aAltSprite, 1)
  384.     set the stretch of sprite aAltSprite to 0
  385.     set the castNum of sprite aAltSprite to cast aMAwhatNum
  386.     set the loc of sprite aAltSprite to getAt(MAgridList, aMAwhichTile)
  387.     set the visible of sprite aAltSprite to 1
  388.   end if
  389. end
  390.  
  391. on MAunCover aMAwhichOne, aMAcolor
  392.   global gMAmatch, gMAlowSprite, gMAoldOne, MAanswergridList, MAclearedGrid, gOldvRot, gMAflip, gMAcurNameLength, MAuniqCharList, gMANumMatches, MAanimList
  393.   set aMAplaceOnGrid to aMAwhichOne - gMAlowSprite + 1
  394.   MAdoAnim(aMAplaceOnGrid, aMAcolor, 0)
  395.   if gMAmatch = EMPTY then
  396.     set gMAmatch to getAt(MArandomGridlist, aMAplaceOnGrid)
  397.     set gMAoldOne to aMAwhichOne
  398.     set gOldvRot to integer(aMAcolor)
  399.   else
  400.     MAtimer(40)
  401.     set aMAright to MAcheckMatch(getAt(MArandomGridlist, aMAplaceOnGrid), gMAmatch)
  402.     set the visible of sprite 41 to 0
  403.     set the visible of sprite 42 to 0
  404.     if aMAright = 1 then
  405.       if gMAsound then
  406.         puppetSound("zap.aif")
  407.         updateStage()
  408.       end if
  409.       setAt(MAclearedGrid, aMAwhichOne - gMAlowSprite + 1, 0)
  410.       setAt(MAclearedGrid, gMAoldOne - gMAlowSprite + 1, 0)
  411.       MAshowLetters()
  412.       if the castNum of sprite 1 = 8 then
  413.         set the castNum of sprite 1 to 13
  414.       else
  415.         set the castNum of sprite 1 to 8
  416.       end if
  417.       updateStage()
  418.       set the locH of sprite aMAwhichOne to -2000
  419.       set the locH of sprite gMAoldOne to -2000
  420.       set gMANumMatches to gMANumMatches + 1
  421.       put "DUCK" && gMANumMatches && count(MAuniqCharList)
  422.       if (gMANumMatches >= count(MAuniqCharList)) and (gMALev = 1) then
  423.         put "DUCK!!"
  424.         MAdoHistory()
  425.       end if
  426.     else
  427.       put "Duck2"
  428.       put aMAcolor
  429.       if gMAsound then
  430.         puppetSound("wssht.aif")
  431.         updateStage()
  432.       end if
  433.       MAdoAnim(aMAplaceOnGrid, aMAcolor, 1)
  434.       set vRot to integer(aMAcolor)
  435.       MAsetTile(aMAwhichOne - gMAlowSprite + 1, getAt(getAt(MAanimList, vRot), 1))
  436.       put aMAcolor
  437.       MAdoAnim(gMAoldOne - gMAlowSprite + 1, aMAcolor, 1)
  438.       MAsetTile(gMAoldOne - gMAlowSprite + 1, getAt(getAt(MAanimList, gOldvRot), 1))
  439.       put aMAcolor
  440.       set the visible of sprite 41 to 0
  441.       set the visible of sprite 42 to 0
  442.     end if
  443.     set gMAmatch to EMPTY
  444.   end if
  445. end
  446.  
  447. on MAdoAnim aMAwhere, aMAwhichColor, aMAbackward
  448.   global MAanswergridList, MAanimList, gMAlowSprite, gMAflip, gMAmatch
  449.   if gMAsound then
  450.     puppetSound("flip.aif")
  451.   end if
  452.   if gMAflip = 1 then
  453.     if aMAbackward = 1 then
  454.       repeat with N = 6 down to 2
  455.         MAsetTile(aMAwhere, getAt(getAt(MAanimList, aMAwhichColor), N))
  456.         updateStage()
  457.         MAtimer(3)
  458.       end repeat
  459.     else
  460.       repeat with N = 1 to 6
  461.         MAsetTile(aMAwhere, getAt(getAt(MAanimList, aMAwhichColor), N))
  462.         updateStage()
  463.         MAtimer(5)
  464.       end repeat
  465.       set the trails of sprite (aMAwhere + gMAlowSprite - 1) to 1
  466.       MAsetTile(aMAwhere, getAt(getAt(MAanimList, aMAwhichColor), 7))
  467.       updateStage()
  468.       MAsetTile(aMAwhere, getProp(MAuniqueIconList, getaProp(MAanswergridList, aMAwhere)), 41 + (gMAmatch = EMPTY))
  469.     end if
  470.     set the trails of sprite (aMAwhere + gMAlowSprite - 1) to 0
  471.     updateStage()
  472.   end if
  473.   if gMAflip = 0 then
  474.     MAsetTile(aMAwhere, getAt(getAt(MAanimList, aMAwhichColor), 7))
  475.     updateStage()
  476.     MAsetTile(aMAwhere, getProp(MAuniqueIconList, getaProp(MAanswergridList, aMAwhere)), 41 + (gMAmatch = EMPTY))
  477.     updateStage()
  478.   end if
  479. end
  480.  
  481. on MAcheckMatch aMAisThis, aMAthis
  482.   set aMAright to 0
  483.   if aMAisThis = aMAthis then
  484.     set aMAright to 1
  485.   else
  486.     set aMAright to 0
  487.   end if
  488.   return aMAright
  489. end
  490.  
  491. on MAshowLetters
  492.   global gMAcurrAth, MAanswergridList, MAclearedGrid, gMAlowLetterSprite, gMAcurNameLength, gMALev, gMAblanks, gMAspacelessName
  493.   repeat with N = 1 to 24
  494.     if getAt(MAclearedGrid, N) = 0 then
  495.       repeat with X = 1 to gMAcurNameLength + gMAblanks
  496.         if gMALev <> 2 then
  497.           if char X of gMAcurrAth = string(getAt(MAanswergridList, N)) then
  498.             if gMALev < 3 then
  499.               puppetSprite(X + gMAlowLetterSprite - 1, 1)
  500.               set the castNum of sprite (X + gMAlowLetterSprite - 1) to cast getAt(MAanswergridList, N)
  501.               if gMAsound then
  502.                 puppetSound("pong.aif")
  503.                 updateStage()
  504.               end if
  505.             end if
  506.             if gMALev > 2 then
  507.               set the loc of sprite (X + gMAlowLetterSprite - 1) to point(5 + (X * 33), 464)
  508.               if gMAsound then
  509.                 puppetSound("pong.aif")
  510.                 updateStage()
  511.               end if
  512.             end if
  513.           end if
  514.         end if
  515.         if gMALev = 2 then
  516.           if char X of gMAspacelessName = string(getAt(MAanswergridList, N)) then
  517.             puppetSprite(X + gMAlowLetterSprite - 1, 1)
  518.             set the castNum of sprite (X + gMAlowLetterSprite - 1) to cast getAt(MAanswergridList, N)
  519.             if gMAsound then
  520.               puppetSound("pong.aif")
  521.               updateStage()
  522.             end if
  523.           end if
  524.         end if
  525.       end repeat
  526.     end if
  527.   end repeat
  528. end
  529.  
  530. on makeAnswerGridList fromWhatList
  531.   global MAuniqueIconList
  532.   set thisList to list()
  533.   repeat with N = 1 to 24
  534.     if getAt(fromWhatList, N) > 0 then
  535.       append(thisList, string(getPropAt(MAuniqueIconList, getAt(fromWhatList, N))))
  536.       next repeat
  537.     end if
  538.     append(thisList, 0)
  539.   end repeat
  540.   return thisList
  541. end
  542.  
  543. on makeRandomGrid withHowMany
  544.   set usedList to [:]
  545.   repeat with N = 1 to 24
  546.     addProp(usedList, N, 0)
  547.   end repeat
  548.   set N to 1
  549.   repeat while N < (withHowMany + 1)
  550.     set try to EMPTY
  551.     repeat while try = EMPTY
  552.       set try to random(24)
  553.       if getAt(usedList, try) = 0 then
  554.         setAt(usedList, try, N)
  555.         set try to EMPTY
  556.         repeat while try = EMPTY
  557.           set try to random(24)
  558.           if getAt(usedList, try) = 0 then
  559.             setAt(usedList, try, N)
  560.             set N to N + 1
  561.             next repeat
  562.           end if
  563.           set try to EMPTY
  564.         end repeat
  565.         next repeat
  566.       end if
  567.       set try to EMPTY
  568.     end repeat
  569.   end repeat
  570.   return usedList
  571. end
  572.  
  573. on MAallOFF
  574.   MAturnPuppets(1, 48, 1)
  575.   MAturnVisible(1, 48, 1)
  576.   MAturnPuppets(1, 48, 0)
  577. end
  578.  
  579. on tellLoc
  580.   repeat with N = 16 to 39
  581.     put the loc of sprite N
  582.   end repeat
  583. end
  584.  
  585. on goSetUp MAnewGame
  586.   global MAgridList, gMAlowSprite, gMAlowLetterSprite, gMAcurrAth, MAathList, MAunusedAthList, gMAcurNameLength, gMAblanks, gMAcurrAthNum, MAuniqCharList, gMAspacelessName, MAflavor, MAmenuList, mouseUp, gMAnextLev, gMAathStr, mouseUp, gMALev
  587.   clearBoard()
  588.   set gMALev to gMAnextLev
  589.   if MAnewGame = 1 then
  590.     set gMANumMatches to 0
  591.     set MAunusedAthList to value(string(MAathList))
  592.     set N to count(MAunusedAthList)
  593.     set vMArandomAthlete to random(N)
  594.     set gMAcurrAth to getPropAt(MAunusedAthList, vMArandomAthlete)
  595.     set gMAcurrAthNum to getAt(MAunusedAthList, vMArandomAthlete)
  596.     set MAflavor to getAt(MAmenuList, 1)
  597.   end if
  598.   set gMAspacelessName to gMAcurrAth
  599.   repeat with I = 1 to length(gMAspacelessName)
  600.     if char I of gMAspacelessName = " " then
  601.       delete char I of gMAspacelessName
  602.     end if
  603.   end repeat
  604.   if gMALev = 2 then
  605.     set vMAname to gMAspacelessName
  606.     set vMAnum to length(gMAspacelessName)
  607.     set X to EMPTY
  608.     repeat with I = 1 to length(gMAspacelessName)
  609.       set N to random(vMAnum)
  610.       set X to char N of vMAname
  611.       delete char N of vMAname
  612.       set vMAscrambledName to string(vMAscrambledName & X)
  613.       set vMAnum to vMAnum - 1
  614.     end repeat
  615.     set gMAspacelessName to vMAscrambledName
  616.   end if
  617.   set gMAathStr to string(gMAcurrAthNum)
  618.   if length(gMAathStr) = 1 then
  619.     set gMAathStr to string("00" & gMAcurrAthNum)
  620.   else
  621.     if length(gMAathStr) = 2 then
  622.       set gMAathStr to string("0" & gMAcurrAthNum)
  623.     end if
  624.   end if
  625.   setUpCards(MAnewGame)
  626.   if gMALev <> 2 then
  627.     set theChar to char 1 of gMAcurrAth
  628.     set N to 1
  629.     set vMAblankCount to 0
  630.     repeat while theChar <> EMPTY
  631.       puppetSprite(N + gMAlowLetterSprite - 1, 1)
  632.       if char N of gMAcurrAth = " " then
  633.         set the castNum of sprite (N + gMAlowLetterSprite - 1) to cast string("blank")
  634.         set vMAblankCount to vMAblankCount + 1
  635.       else
  636.         set the castNum of sprite (N + gMAlowLetterSprite - 1) to cast string("dash")
  637.       end if
  638.       if gMALev < 2 then
  639.         set the loc of sprite (N + gMAlowLetterSprite - 1) to point(5 + (N * 33), 464)
  640.       end if
  641.       if gMALev > 2 then
  642.         set the loc of sprite (N + gMAlowLetterSprite - 1) to point(5 + (N * 33), 1000)
  643.       else
  644.         if gMAsound then
  645.           puppetSound("schwak.aif")
  646.           updateStage()
  647.         end if
  648.         updateStage()
  649.         set vNewTime to the timer + 15
  650.         repeat while the timer < vNewTime
  651.           nothing()
  652.         end repeat
  653.       end if
  654.       set N to N + 1
  655.       set theChar to char N of gMAcurrAth
  656.     end repeat
  657.   end if
  658.   if gMALev = 2 then
  659.     set theChar to char 1 of gMAspacelessName
  660.     set N to 1
  661.     set vMAblankCount to 0
  662.     repeat while theChar <> EMPTY
  663.       puppetSprite(N + gMAlowLetterSprite - 1, 1)
  664.       set the castNum of sprite (N + gMAlowLetterSprite - 1) to cast string("dash")
  665.       set the loc of sprite (N + gMAlowLetterSprite - 1) to point(5 + (N * 33), 464)
  666.       set N to N + 1
  667.       set theChar to char N of gMAspacelessName
  668.     end repeat
  669.   end if
  670.   set gMAcurNameLength to N - 1 - vMAblankCount
  671.   set gMAblanks to vMAblankCount
  672. end
  673.  
  674. on setUpCards MAnewGame
  675.   global uniquePairList, MAuniqueIconList, gMAcurNameLength, MArandomGridlist, MAanswergridList, MAclearedGrid, MAcharList, gMAcurrAth, gMAspacelessName, gMALev, MAuniqCharList
  676.   if MAnewGame = 1 then
  677.     set MAcharList to []
  678.     set vMAcharNums to length(gMAspacelessName)
  679.     repeat with vMAi = 1 to vMAcharNums
  680.       append(MAcharList, char vMAi of gMAspacelessName)
  681.     end repeat
  682.     set vMAnum to length(gMAspacelessName)
  683.     set MAuniqCharList to []
  684.     repeat with vMAi = 1 to vMAnum
  685.       set vChr to char vMAi of gMAspacelessName
  686.       set vFlag to 1
  687.       repeat with vMAn = vMAi - 1 down to 1
  688.         if vChr = char vMAn of gMAspacelessName then
  689.           set vFlag to 0
  690.           exit repeat
  691.         end if
  692.       end repeat
  693.       if vFlag then
  694.         add(MAuniqCharList, vChr)
  695.       end if
  696.     end repeat
  697.     MAdoUniqueIconList()
  698.     set MArandomGridlist to makeRandomGrid(count(MAuniqueIconList))
  699.     set MAanswergridList to makeAnswerGridList(MArandomGridlist)
  700.   end if
  701.   repeat with N = 1 to count(MAuniqueIconList)
  702.     set a to 0
  703.     set X to 0
  704.     repeat while a = 0
  705.       set X to X + 1
  706.       set a to getAt(MArandomGridlist, X)
  707.       if a = N then
  708.         set a to X
  709.         next repeat
  710.       end if
  711.       set a to 0
  712.     end repeat
  713.     set b to 0
  714.     repeat while b = 0
  715.       set X to X + 1
  716.       set b to getAt(MArandomGridlist, X)
  717.       if b = N then
  718.         set b to X
  719.         next repeat
  720.       end if
  721.       set b to 0
  722.     end repeat
  723.     if getAt(MAclearedGrid, a) = 1 then
  724.       set num to getAt(getAt(MAanimList, integer(char 8 of the name of cast getAt(MAuniqueIconList, N))), 1)
  725.       MAsetTile(a, num)
  726.       if gMAsound then
  727.         puppetSound("deal.aif")
  728.       end if
  729.       updateStage()
  730.       set vNewTime to the timer + 15
  731.       repeat while the timer < vNewTime
  732.         nothing()
  733.       end repeat
  734.       MAsetTile(b, num)
  735.       if gMAsound then
  736.         puppetSound("deal.aif")
  737.       end if
  738.     end if
  739.     updateStage()
  740.     set vNewTime to the timer + 15
  741.     repeat while the timer < vNewTime
  742.       nothing()
  743.     end repeat
  744.   end repeat
  745. end
  746.  
  747. on GetCurrMenu
  748.   global gMAnextLev, gMAsound, gMAflip
  749.   set vMenu to "menu" & gMAnextLev
  750.   if gMAsound then
  751.     if gMAflip then
  752.       set vSfx to "a"
  753.     else
  754.       set vSfx to "c"
  755.     end if
  756.   else
  757.     if gMAflip then
  758.       set vSfx to "b"
  759.     else
  760.       set vSfx to "d"
  761.     end if
  762.   end if
  763.   set vMenu to vMenu & vSfx
  764.   return the number of cast vMenu
  765. end
  766.